package com.google.code.resistorboy;

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import org.netbeans.microedition.lcdui.SplashScreen;

/**
 * ResistorBoy main class.
 * @author Leandro Nunes
 */
public class HelloMIDlet extends MIDlet implements CommandListener {

    private boolean midletPaused = false;
    private static int bandCounter = 0;

    //<editor-fold defaultstate="collapsed" desc=" Generated Fields ">//GEN-BEGIN:|fields|0|
    private Command exitCommand;
    private Command backCommand;
    private Command okCommand;
    private Command screenCommand;
    private Command back4Band;
    private Command ok5Band;
    private Command ok4Band;
    private Command back5Band;
    private Command back6Band;
    private Command ok6Band;
    private Command stopCommand;
    private SplashScreen splash;
    private List frmMenu;
    private Form frm4Band;
    private ChoiceGroup a4Band;
    private ChoiceGroup b4Band;
    private ChoiceGroup c4Band;
    private ChoiceGroup d4Band;
    private Alert frmAbout;
    private Alert frmResult;
    private Form frm5Band;
    private ChoiceGroup a5Band;
    private ChoiceGroup b5Band;
    private ChoiceGroup c5Band;
    private ChoiceGroup d5Band;
    private ChoiceGroup e5Band;
    private Form frm6Band;
    private ChoiceGroup d6Band;
    private ChoiceGroup c6Band;
    private ChoiceGroup b6Band;
    private ChoiceGroup a6Band;
    private ChoiceGroup f6Band;
    private ChoiceGroup e6Band;
    private Image image;
    //</editor-fold>//GEN-END:|fields|0|

    /**
     * The HelloMIDlet constructor.
     */
    public HelloMIDlet() {
    }

    //<editor-fold defaultstate="collapsed" desc=" Generated Methods ">//GEN-BEGIN:|methods|0|
    //</editor-fold>//GEN-END:|methods|0|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: initialize ">//GEN-BEGIN:|0-initialize|0|0-preInitialize
    /**
     * Initilizes the application.
     * It is called only once when the MIDlet is started. The method is called before the <code>startMIDlet</code> method.
     */
    private void initialize() {//GEN-END:|0-initialize|0|0-preInitialize
        // write pre-initialize user code here
//GEN-LINE:|0-initialize|1|0-postInitialize
        // write post-initialize user code here
    }//GEN-BEGIN:|0-initialize|2|
    //</editor-fold>//GEN-END:|0-initialize|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: startMIDlet ">//GEN-BEGIN:|3-startMIDlet|0|3-preAction
    /**
     * Performs an action assigned to the Mobile Device - MIDlet Started point.
     */
    public void startMIDlet() {//GEN-END:|3-startMIDlet|0|3-preAction
        // write pre-action user code here
        switchDisplayable(null, getSplash());//GEN-LINE:|3-startMIDlet|1|3-postAction
        // write post-action user code here
    }//GEN-BEGIN:|3-startMIDlet|2|
    //</editor-fold>//GEN-END:|3-startMIDlet|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: resumeMIDlet ">//GEN-BEGIN:|4-resumeMIDlet|0|4-preAction
    /**
     * Performs an action assigned to the Mobile Device - MIDlet Resumed point.
     */
    public void resumeMIDlet() {//GEN-END:|4-resumeMIDlet|0|4-preAction
        // write pre-action user code here
//GEN-LINE:|4-resumeMIDlet|1|4-postAction
        // write post-action user code here
    }//GEN-BEGIN:|4-resumeMIDlet|2|
    //</editor-fold>//GEN-END:|4-resumeMIDlet|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: switchDisplayable ">//GEN-BEGIN:|5-switchDisplayable|0|5-preSwitch
    /**
     * Switches a current displayable in a display. The <code>display</code> instance is taken from <code>getDisplay</code> method. This method is used by all actions in the design for switching displayable.
     * @param alert the Alert which is temporarily set to the display; if <code>null</code>, then <code>nextDisplayable</code> is set immediately
     * @param nextDisplayable the Displayable to be set
     */
    public void switchDisplayable(Alert alert, Displayable nextDisplayable) {//GEN-END:|5-switchDisplayable|0|5-preSwitch
        // write pre-switch user code here
        Display display = getDisplay();//GEN-BEGIN:|5-switchDisplayable|1|5-postSwitch
        if (alert == null) {
            display.setCurrent(nextDisplayable);
        } else {
            display.setCurrent(alert, nextDisplayable);
        }//GEN-END:|5-switchDisplayable|1|5-postSwitch
        // write post-switch user code here
    }//GEN-BEGIN:|5-switchDisplayable|2|
    //</editor-fold>//GEN-END:|5-switchDisplayable|2|



    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: exitCommand ">//GEN-BEGIN:|18-getter|0|18-preInit
    /**
     * Returns an initiliazed instance of exitCommand component.
     * @return the initialized component instance
     */
    public Command getExitCommand() {
        if (exitCommand == null) {//GEN-END:|18-getter|0|18-preInit
            // write pre-init user code here
            exitCommand = new Command("Exit", Command.EXIT, 0);//GEN-LINE:|18-getter|1|18-postInit
            // write post-init user code here
        }//GEN-BEGIN:|18-getter|2|
        return exitCommand;
    }
    //</editor-fold>//GEN-END:|18-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: commandAction for Displayables ">//GEN-BEGIN:|7-commandAction|0|7-preCommandAction
    /**
     * Called by a system to indicated that a command has been invoked on a particular displayable.
     * @param command the Command that was invoked
     * @param displayable the Displayable where the command was invoked
     */
    public void commandAction(Command command, Displayable displayable) {//GEN-END:|7-commandAction|0|7-preCommandAction
        // write pre-action user code here
        if (displayable == frm4Band) {//GEN-BEGIN:|7-commandAction|1|53-preAction
            if (command == back4Band) {//GEN-END:|7-commandAction|1|53-preAction
                // write pre-action user code here
                switchDisplayable(null, getFrmMenu());//GEN-LINE:|7-commandAction|2|53-postAction
                // write post-action user code here
            } else if (command == ok4Band) {//GEN-LINE:|7-commandAction|3|99-preAction
                // write pre-action user code here
                getFrmResult().setString(
                        (ResistorCalculator.calculate(
                        getA4Band().getSelectedIndex(),
                        getB4Band().getSelectedIndex(),
                        getC4Band().getSelectedIndex(),
                        getD4Band().getSelectedIndex())).toString());

                switchDisplayable(getFrmResult(), getFrm4Band());//GEN-LINE:|7-commandAction|4|99-postAction
                // write post-action user code here
            }//GEN-BEGIN:|7-commandAction|5|106-preAction
        } else if (displayable == frm5Band) {
            if (command == back5Band) {//GEN-END:|7-commandAction|5|106-preAction
                // write pre-action user code here
                switchDisplayable(null, getFrmMenu());//GEN-LINE:|7-commandAction|6|106-postAction
                // write post-action user code here
            } else if (command == ok5Band) {//GEN-LINE:|7-commandAction|7|102-preAction
                // write pre-action user code here
                getFrmResult().setString(
                        (ResistorCalculator.calculate(
                        getA5Band().getSelectedIndex(),
                        getB5Band().getSelectedIndex(),
                        getC5Band().getSelectedIndex(),
                        getD5Band().getSelectedIndex(),
                        getE5Band().getSelectedIndex())).toString());
                switchDisplayable(getFrmResult(), getFrm5Band());//GEN-LINE:|7-commandAction|8|102-postAction
                // write post-action user code here
            }//GEN-BEGIN:|7-commandAction|9|164-preAction
        } else if (displayable == frm6Band) {
            if (command == back6Band) {//GEN-END:|7-commandAction|9|164-preAction
                // write pre-action user code here
                switchDisplayable(null, getFrmMenu());//GEN-LINE:|7-commandAction|10|164-postAction
                // write post-action user code here
            } else if (command == ok6Band) {//GEN-LINE:|7-commandAction|11|162-preAction
                // write pre-action user code here
                getFrmResult().setString(
                        (ResistorCalculator.calculate(
                        getA6Band().getSelectedIndex(),
                        getB6Band().getSelectedIndex(),
                        getC6Band().getSelectedIndex(),
                        getD6Band().getSelectedIndex(),
                        getE6Band().getSelectedIndex(),
                        getF6Band().getSelectedIndex())).toString());
                switchDisplayable(getFrmResult(), getFrm6Band());//GEN-LINE:|7-commandAction|12|162-postAction
                // write post-action user code here
            }//GEN-BEGIN:|7-commandAction|13|28-preAction
        } else if (displayable == frmMenu) {
            if (command == List.SELECT_COMMAND) {//GEN-END:|7-commandAction|13|28-preAction
                // write pre-action user code here
                frmMenuAction();//GEN-LINE:|7-commandAction|14|28-postAction
                // write post-action user code here
            }//GEN-BEGIN:|7-commandAction|15|24-preAction
        } else if (displayable == splash) {
            if (command == SplashScreen.DISMISS_COMMAND) {//GEN-END:|7-commandAction|15|24-preAction
                // write pre-action user code here
                switchDisplayable(null, getFrmMenu());//GEN-LINE:|7-commandAction|16|24-postAction
                // write post-action user code here
            }//GEN-BEGIN:|7-commandAction|17|7-postCommandAction
        }//GEN-END:|7-commandAction|17|7-postCommandAction
        // write post-action user code here
    }//GEN-BEGIN:|7-commandAction|18|
    //</editor-fold>//GEN-END:|7-commandAction|18|


    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: splash ">//GEN-BEGIN:|22-getter|0|22-preInit
    /**
     * Returns an initiliazed instance of splash component.
     * @return the initialized component instance
     */
    public SplashScreen getSplash() {
        if (splash == null) {//GEN-END:|22-getter|0|22-preInit
            // write pre-init user code here
            splash = new SplashScreen(getDisplay());//GEN-BEGIN:|22-getter|1|22-postInit
            splash.setTitle("splashScreen");
            splash.setCommandListener(this);
            splash.setFullScreenMode(true);
            splash.setImage(getImage());//GEN-END:|22-getter|1|22-postInit
            // write post-init user code here
        }//GEN-BEGIN:|22-getter|2|
        return splash;
    }
    //</editor-fold>//GEN-END:|22-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: frmMenu ">//GEN-BEGIN:|26-getter|0|26-preInit
    /**
     * Returns an initiliazed instance of frmMenu component.
     * @return the initialized component instance
     */
    public List getFrmMenu() {
        if (frmMenu == null) {//GEN-END:|26-getter|0|26-preInit
            // write pre-init user code here
            frmMenu = new List("Main menu", Choice.IMPLICIT);//GEN-BEGIN:|26-getter|1|26-postInit
            frmMenu.append("4 bands", null);
            frmMenu.append("5 bands", null);
            frmMenu.append("6 bands", null);
            frmMenu.append("About", null);
            frmMenu.append("Exit", null);
            frmMenu.setCommandListener(this);
            frmMenu.setSelectedFlags(new boolean[] { false, false, false, false, false });//GEN-END:|26-getter|1|26-postInit
            // write post-init user code here
        }//GEN-BEGIN:|26-getter|2|
        return frmMenu;
    }
    //</editor-fold>//GEN-END:|26-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: frmMenuAction ">//GEN-BEGIN:|26-action|0|26-preAction
    /**
     * Performs an action assigned to the selected list element in the frmMenu component.
     */
    public void frmMenuAction() {//GEN-END:|26-action|0|26-preAction
        // enter pre-action user code here
        String __selectedString = getFrmMenu().getString(getFrmMenu().getSelectedIndex());//GEN-BEGIN:|26-action|1|31-preAction
        if (__selectedString != null) {
            if (__selectedString.equals("4 bands")) {//GEN-END:|26-action|1|31-preAction
                bandCounter = 4;
                switchDisplayable(null, getFrm4Band());//GEN-LINE:|26-action|2|31-postAction
                // write post-action user code here
            } else if (__selectedString.equals("5 bands")) {//GEN-LINE:|26-action|3|32-preAction
                bandCounter = 5;
                switchDisplayable(null, getFrm5Band());//GEN-LINE:|26-action|4|32-postAction
                // post-action
            } else if (__selectedString.equals("6 bands")) {//GEN-LINE:|26-action|5|33-preAction
                bandCounter = 6;
                switchDisplayable(null, getFrm6Band());//GEN-LINE:|26-action|6|33-postAction
                // write post-action user code here
            } else if (__selectedString.equals("About")) {//GEN-LINE:|26-action|7|34-preAction
                // write pre-action user code here
                switchDisplayable(getFrmAbout(), getFrmMenu());//GEN-LINE:|26-action|8|34-postAction
                // write post-action user code here
            } else if (__selectedString.equals("Exit")) {//GEN-LINE:|26-action|9|35-preAction
                // write pre-action user code here
                exitMIDlet();//GEN-LINE:|26-action|10|35-postAction
                // write post-action user code here
            }//GEN-BEGIN:|26-action|11|26-postAction
        }//GEN-END:|26-action|11|26-postAction
        // enter post-action user code here
    }//GEN-BEGIN:|26-action|12|
    //</editor-fold>//GEN-END:|26-action|12|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommand ">//GEN-BEGIN:|41-getter|0|41-preInit
    /**
     * Returns an initiliazed instance of backCommand component.
     * @return the initialized component instance
     */
    public Command getBackCommand() {
        if (backCommand == null) {//GEN-END:|41-getter|0|41-preInit
            // write pre-init user code here
            backCommand = new Command("Back", Command.BACK, 0);//GEN-LINE:|41-getter|1|41-postInit
            // write post-init user code here
        }//GEN-BEGIN:|41-getter|2|
        return backCommand;
    }
    //</editor-fold>//GEN-END:|41-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: okCommand ">//GEN-BEGIN:|44-getter|0|44-preInit
    /**
     * Returns an initiliazed instance of okCommand component.
     * @return the initialized component instance
     */
    public Command getOkCommand() {
        if (okCommand == null) {//GEN-END:|44-getter|0|44-preInit
            // write pre-init user code here
            okCommand = new Command("Ok", Command.OK, 0);//GEN-LINE:|44-getter|1|44-postInit
            // write post-init user code here
        }//GEN-BEGIN:|44-getter|2|
        return okCommand;
    }
    //</editor-fold>//GEN-END:|44-getter|2|
    //</editor-fold>
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: frm4Band ">//GEN-BEGIN:|38-getter|0|38-preInit
    /**
     * Returns an initiliazed instance of frm4Band component.
     * @return the initialized component instance
     */
    public Form getFrm4Band() {
        if (frm4Band == null) {//GEN-END:|38-getter|0|38-preInit

            frm4Band = new Form("4 bands resistor", new Item[] { getA4Band(), getB4Band(), getC4Band(), getD4Band() });//GEN-BEGIN:|38-getter|1|38-postInit
            frm4Band.addCommand(getOk4Band());
            frm4Band.addCommand(getBack4Band());
            frm4Band.setCommandListener(this);//GEN-END:|38-getter|1|38-postInit



        }//GEN-BEGIN:|38-getter|2|
        return frm4Band;
    }
    //</editor-fold>//GEN-END:|38-getter|2|



    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: frmAbout ">//GEN-BEGIN:|47-getter|0|47-preInit
    /**
     * Returns an initiliazed instance of frmAbout component.
     * @return the initialized component instance
     */
    public Alert getFrmAbout() {
        if (frmAbout == null) {//GEN-END:|47-getter|0|47-preInit
            // write pre-init user code here
            frmAbout = new Alert("About", "Resistor boy is a free software, developed by Leandro Nunes and Bruno Schmitt.", null, null);//GEN-BEGIN:|47-getter|1|47-postInit
            frmAbout.setTimeout(Alert.FOREVER);//GEN-END:|47-getter|1|47-postInit
            // write post-init user code here
        }//GEN-BEGIN:|47-getter|2|
        return frmAbout;
    }
    //</editor-fold>//GEN-END:|47-getter|2|
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: back4Band ">//GEN-BEGIN:|52-getter|0|52-preInit
    /**
     * Returns an initiliazed instance of back4Band component.
     * @return the initialized component instance
     */
    public Command getBack4Band() {
        if (back4Band == null) {//GEN-END:|52-getter|0|52-preInit
            // write pre-init user code here
            back4Band = new Command("Back", Command.BACK, 0);//GEN-LINE:|52-getter|1|52-postInit
            // write post-init user code here
        }//GEN-BEGIN:|52-getter|2|
        return back4Band;
    }
    //</editor-fold>//GEN-END:|52-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: screenCommand ">//GEN-BEGIN:|55-getter|0|55-preInit
    /**
     * Returns an initiliazed instance of screenCommand component.
     * @return the initialized component instance
     */
    public Command getScreenCommand() {
        if (screenCommand == null) {//GEN-END:|55-getter|0|55-preInit
            // write pre-init user code here
            screenCommand = new Command("Screen", Command.SCREEN, 0);//GEN-LINE:|55-getter|1|55-postInit
            // write post-init user code here
        }//GEN-BEGIN:|55-getter|2|
        return screenCommand;
    }
    //</editor-fold>//GEN-END:|55-getter|2|
    //</editor-fold>
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: a4Band ">//GEN-BEGIN:|59-getter|0|59-preInit
    /**
     * Returns an initiliazed instance of a4Band component.
     * @return the initialized component instance
     */
    public ChoiceGroup getA4Band() {
        if (a4Band == null) {//GEN-END:|59-getter|0|59-preInit
            // write pre-init user code here
            a4Band = new ChoiceGroup("A band", Choice.POPUP);//GEN-BEGIN:|59-getter|1|59-postInit
            a4Band.append("Brown", null);
            a4Band.append("Red", null);
            a4Band.append("Orange", null);
            a4Band.append("Yellow", null);
            a4Band.append("Green", null);
            a4Band.append("Blue", null);
            a4Band.append("Violet", null);
            a4Band.append("Gray", null);
            a4Band.append("White", null);
            a4Band.setSelectedFlags(new boolean[] { false, false, false, false, false, false, false, false, false });//GEN-END:|59-getter|1|59-postInit
            // write post-init user code here
        }//GEN-BEGIN:|59-getter|2|
        return a4Band;
    }
    //</editor-fold>//GEN-END:|59-getter|2|
    //</editor-fold>
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: b4Band ">//GEN-BEGIN:|70-getter|0|70-preInit
    /**
     * Returns an initiliazed instance of b4Band component.
     * @return the initialized component instance
     */
    public ChoiceGroup getB4Band() {
        if (b4Band == null) {//GEN-END:|70-getter|0|70-preInit
            // write pre-init user code here
            b4Band = new ChoiceGroup("B band", Choice.POPUP);//GEN-BEGIN:|70-getter|1|70-postInit
            b4Band.append("Black", null);
            b4Band.append("Brown", null);
            b4Band.append("Red", null);
            b4Band.append("Orange", null);
            b4Band.append("Yellow", null);
            b4Band.append("Green", null);
            b4Band.append("Blue", null);
            b4Band.append("Violet", null);
            b4Band.append("Gray", null);
            b4Band.append("White", null);
            b4Band.setSelectedFlags(new boolean[] { false, false, false, false, false, false, false, false, false, false });//GEN-END:|70-getter|1|70-postInit
            // write post-init user code here
        }//GEN-BEGIN:|70-getter|2|
        return b4Band;
    }
    //</editor-fold>//GEN-END:|70-getter|2|
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: c4Band ">//GEN-BEGIN:|81-getter|0|81-preInit
    /**
     * Returns an initiliazed instance of c4Band component.
     * @return the initialized component instance
     */
    public ChoiceGroup getC4Band() {
        if (c4Band == null) {//GEN-END:|81-getter|0|81-preInit
            // write pre-init user code here
            c4Band = new ChoiceGroup("C band", Choice.POPUP);//GEN-BEGIN:|81-getter|1|81-postInit
            c4Band.append("Black", null);
            c4Band.append("Brown", null);
            c4Band.append("Red", null);
            c4Band.append("Orange", null);
            c4Band.append("Yellow", null);
            c4Band.append("Green", null);
            c4Band.append("Blue", null);
            c4Band.append("Violet", null);
            c4Band.append("Gold", null);
            c4Band.append("Silver", null);
            c4Band.setSelectedFlags(new boolean[] { false, false, false, false, false, false, false, false, false, false });//GEN-END:|81-getter|1|81-postInit
            // write post-init user code here
        }//GEN-BEGIN:|81-getter|2|
        return c4Band;
    }
    //</editor-fold>//GEN-END:|81-getter|2|
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: d4Band ">//GEN-BEGIN:|91-getter|0|91-preInit
    /**
     * Returns an initiliazed instance of d4Band component.
     * @return the initialized component instance
     */
    public ChoiceGroup getD4Band() {
        if (d4Band == null) {//GEN-END:|91-getter|0|91-preInit
            // write pre-init user code here
            d4Band = new ChoiceGroup("Tolerance", Choice.POPUP);//GEN-BEGIN:|91-getter|1|91-postInit
            d4Band.append("Brown", null);
            d4Band.append("Red", null);
            d4Band.append("Gold", null);
            d4Band.append("Silver", null);
            d4Band.setSelectedFlags(new boolean[] { false, false, false, false });//GEN-END:|91-getter|1|91-postInit
            // write post-init user code here
        }//GEN-BEGIN:|91-getter|2|
        return d4Band;
    }
    //</editor-fold>//GEN-END:|91-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: frmResult ">//GEN-BEGIN:|96-getter|0|96-preInit
    /**
     * Returns an initiliazed instance of frmResult component.
     * @return the initialized component instance
     */
    public Alert getFrmResult() {
        if (frmResult == null) {//GEN-END:|96-getter|0|96-preInit
            // write pre-init user code here
            frmResult = new Alert("Result");//GEN-BEGIN:|96-getter|1|96-postInit
            frmResult.setTimeout(Alert.FOREVER);//GEN-END:|96-getter|1|96-postInit
            // write post-init user code here
        }//GEN-BEGIN:|96-getter|2|
        return frmResult;
    }
    //</editor-fold>//GEN-END:|96-getter|2|
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: ok4Band ">//GEN-BEGIN:|98-getter|0|98-preInit
    /**
     * Returns an initiliazed instance of ok4Band component.
     * @return the initialized component instance
     */
    public Command getOk4Band() {
        if (ok4Band == null) {//GEN-END:|98-getter|0|98-preInit
            // write pre-init user code here
            ok4Band = new Command("Ok", Command.OK, 0);//GEN-LINE:|98-getter|1|98-postInit
            // write post-init user code here
        }//GEN-BEGIN:|98-getter|2|
        return ok4Band;
    }
    //</editor-fold>//GEN-END:|98-getter|2|
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: ok5Band ">//GEN-BEGIN:|101-getter|0|101-preInit
    /**
     * Returns an initiliazed instance of ok5Band component.
     * @return the initialized component instance
     */
    public Command getOk5Band() {
        if (ok5Band == null) {//GEN-END:|101-getter|0|101-preInit
            // write pre-init user code here
            ok5Band = new Command("Ok", Command.OK, 0);//GEN-LINE:|101-getter|1|101-postInit
            // write post-init user code here
        }//GEN-BEGIN:|101-getter|2|
        return ok5Band;
    }
    //</editor-fold>//GEN-END:|101-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: frm5Band ">//GEN-BEGIN:|97-getter|0|97-preInit
    /**
     * Returns an initiliazed instance of frm5Band component.
     * @return the initialized component instance
     */
    public Form getFrm5Band() {
        if (frm5Band == null) {//GEN-END:|97-getter|0|97-preInit
            // write pre-init user code here
            frm5Band = new Form("5 bands resistor", new Item[] { getA5Band(), getB5Band(), getC5Band(), getD5Band(), getE5Band() });//GEN-BEGIN:|97-getter|1|97-postInit
            frm5Band.addCommand(getOk5Band());
            frm5Band.addCommand(getBack5Band());
            frm5Band.setCommandListener(this);//GEN-END:|97-getter|1|97-postInit
            // write post-init user code here
        }//GEN-BEGIN:|97-getter|2|
        return frm5Band;
    }
    //</editor-fold>//GEN-END:|97-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: back5Band ">//GEN-BEGIN:|105-getter|0|105-preInit
    /**
     * Returns an initiliazed instance of back5Band component.
     * @return the initialized component instance
     */
    public Command getBack5Band() {
        if (back5Band == null) {//GEN-END:|105-getter|0|105-preInit
            // write pre-init user code here
            back5Band = new Command("Back", Command.BACK, 0);//GEN-LINE:|105-getter|1|105-postInit
            // write post-init user code here
        }//GEN-BEGIN:|105-getter|2|
        return back5Band;
    }
    //</editor-fold>//GEN-END:|105-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: frm6Band ">//GEN-BEGIN:|109-getter|0|109-preInit
    /**
     * Returns an initiliazed instance of frm6Band component.
     * @return the initialized component instance
     */
    public Form getFrm6Band() {
        if (frm6Band == null) {//GEN-END:|109-getter|0|109-preInit
            // write pre-init user code here
            frm6Band = new Form("6 bands resistor", new Item[] { getA6Band(), getB6Band(), getC6Band(), getD6Band(), getE6Band(), getF6Band() });//GEN-BEGIN:|109-getter|1|109-postInit
            frm6Band.addCommand(getOk6Band());
            frm6Band.addCommand(getBack6Band());
            frm6Band.setCommandListener(this);//GEN-END:|109-getter|1|109-postInit
            // write post-init user code here
        }//GEN-BEGIN:|109-getter|2|
        return frm6Band;
    }
    //</editor-fold>//GEN-END:|109-getter|2|
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: a5Band ">//GEN-BEGIN:|112-getter|0|112-preInit
    /**
     * Returns an initiliazed instance of a5Band component.
     * @return the initialized component instance
     */
    public ChoiceGroup getA5Band() {
        if (a5Band == null) {//GEN-END:|112-getter|0|112-preInit
            // write pre-init user code here
            a5Band = new ChoiceGroup("A band", Choice.POPUP);//GEN-BEGIN:|112-getter|1|112-postInit
            a5Band.append("Brown", null);
            a5Band.append("Red", null);
            a5Band.append("Orange", null);
            a5Band.append("Yellow", null);
            a5Band.append("Green", null);
            a5Band.append("Blue", null);
            a5Band.append("Violet", null);
            a5Band.append("Grey", null);
            a5Band.append("White", null);
            a5Band.setSelectedFlags(new boolean[] { false, false, false, false, false, false, false, false, false });//GEN-END:|112-getter|1|112-postInit
            // write post-init user code here
        }//GEN-BEGIN:|112-getter|2|
        return a5Band;
    }
    //</editor-fold>//GEN-END:|112-getter|2|
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: b5Band ">//GEN-BEGIN:|122-getter|0|122-preInit
    /**
     * Returns an initiliazed instance of b5Band component.
     * @return the initialized component instance
     */
    public ChoiceGroup getB5Band() {
        if (b5Band == null) {//GEN-END:|122-getter|0|122-preInit
            // write pre-init user code here
            b5Band = new ChoiceGroup("B band", Choice.POPUP);//GEN-BEGIN:|122-getter|1|122-postInit
            b5Band.append("Black", null);
            b5Band.append("Brown", null);
            b5Band.append("Red", null);
            b5Band.append("Orange", null);
            b5Band.append("Yellow", null);
            b5Band.append("Green", null);
            b5Band.append("Blue", null);
            b5Band.append("Violet", null);
            b5Band.append("Grey", null);
            b5Band.append("White", null);
            b5Band.setSelectedFlags(new boolean[] { false, false, false, false, false, false, false, false, false, false });//GEN-END:|122-getter|1|122-postInit
            // write post-init user code here
        }//GEN-BEGIN:|122-getter|2|
        return b5Band;
    }
    //</editor-fold>//GEN-END:|122-getter|2|
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: c5Band ">//GEN-BEGIN:|133-getter|0|133-preInit
    /**
     * Returns an initiliazed instance of c5Band component.
     * @return the initialized component instance
     */
    public ChoiceGroup getC5Band() {
        if (c5Band == null) {//GEN-END:|133-getter|0|133-preInit
            // write pre-init user code here
            c5Band = new ChoiceGroup("C band", Choice.POPUP);//GEN-BEGIN:|133-getter|1|133-postInit
            c5Band.append("Black", null);
            c5Band.append("Brown", null);
            c5Band.append("Red", null);
            c5Band.append("Orange", null);
            c5Band.append("Yellow", null);
            c5Band.append("Green", null);
            c5Band.append("Blue", null);
            c5Band.append("Violet", null);
            c5Band.append("Grey", null);
            c5Band.append("White", null);
            c5Band.setSelectedFlags(new boolean[] { false, false, false, false, false, false, false, false, false, false });//GEN-END:|133-getter|1|133-postInit
            // write post-init user code here
        }//GEN-BEGIN:|133-getter|2|
        return c5Band;
    }
    //</editor-fold>//GEN-END:|133-getter|2|
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: d5Band ">//GEN-BEGIN:|135-getter|0|135-preInit
    /**
     * Returns an initiliazed instance of d5Band component.
     * @return the initialized component instance
     */
    public ChoiceGroup getD5Band() {
        if (d5Band == null) {//GEN-END:|135-getter|0|135-preInit
            // write pre-init user code here
            d5Band = new ChoiceGroup("D band", Choice.POPUP);//GEN-BEGIN:|135-getter|1|135-postInit
            d5Band.append("Black", null);
            d5Band.append("Brown", null);
            d5Band.append("Red", null);
            d5Band.append("Orange", null);
            d5Band.append("Yellow", null);
            d5Band.append("Green", null);
            d5Band.append("Blue", null);
            d5Band.append("Violet", null);
            d5Band.append("Grey", null);
            d5Band.append("White", null);
            d5Band.setSelectedFlags(new boolean[] { false, false, false, false, false, false, false, false, false, false });//GEN-END:|135-getter|1|135-postInit
            // write post-init user code here
        }//GEN-BEGIN:|135-getter|2|
        return d5Band;
    }
    //</editor-fold>//GEN-END:|135-getter|2|
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: e5Band ">//GEN-BEGIN:|156-getter|0|156-preInit
    /**
     * Returns an initiliazed instance of e5Band component.
     * @return the initialized component instance
     */
    public ChoiceGroup getE5Band() {
        if (e5Band == null) {//GEN-END:|156-getter|0|156-preInit
            // write pre-init user code here
            e5Band = new ChoiceGroup("Tolerance", Choice.POPUP);//GEN-BEGIN:|156-getter|1|156-postInit
            e5Band.append("Brown", null);
            e5Band.append("Red", null);
            e5Band.append("Gold", null);
            e5Band.append("Silver", null);
            e5Band.setSelectedFlags(new boolean[] { false, false, false, false });//GEN-END:|156-getter|1|156-postInit
            // write post-init user code here
        }//GEN-BEGIN:|156-getter|2|
        return e5Band;
    }
    //</editor-fold>//GEN-END:|156-getter|2|
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: ok6Band ">//GEN-BEGIN:|161-getter|0|161-preInit
    /**
     * Returns an initiliazed instance of ok6Band component.
     * @return the initialized component instance
     */
    public Command getOk6Band() {
        if (ok6Band == null) {//GEN-END:|161-getter|0|161-preInit
            // write pre-init user code here
            ok6Band = new Command("Ok", Command.OK, 0);//GEN-LINE:|161-getter|1|161-postInit
            // write post-init user code here
        }//GEN-BEGIN:|161-getter|2|
        return ok6Band;
    }
    //</editor-fold>//GEN-END:|161-getter|2|
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: back6Band ">//GEN-BEGIN:|163-getter|0|163-preInit
    /**
     * Returns an initiliazed instance of back6Band component.
     * @return the initialized component instance
     */
    public Command getBack6Band() {
        if (back6Band == null) {//GEN-END:|163-getter|0|163-preInit
            // write pre-init user code here
            back6Band = new Command("Back", Command.BACK, 0);//GEN-LINE:|163-getter|1|163-postInit
            // write post-init user code here
        }//GEN-BEGIN:|163-getter|2|
        return back6Band;
    }
    //</editor-fold>//GEN-END:|163-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: image ">//GEN-BEGIN:|167-getter|0|167-preInit
    /**
     * Returns an initiliazed instance of image component.
     * @return the initialized component instance
     */
    public Image getImage() {
        if (image == null) {//GEN-END:|167-getter|0|167-preInit
            // write pre-init user code here
            try {//GEN-BEGIN:|167-getter|1|167-@java.io.IOException
                image = Image.createImage("/resistorBoy.jpg");
            } catch (java.io.IOException e) {//GEN-END:|167-getter|1|167-@java.io.IOException
                e.printStackTrace();
            }//GEN-LINE:|167-getter|2|167-postInit
            // write post-init user code here
        }//GEN-BEGIN:|167-getter|3|
        return image;
    }
    //</editor-fold>//GEN-END:|167-getter|3|
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: a6Band ">//GEN-BEGIN:|168-getter|0|168-preInit
    /**
     * Returns an initiliazed instance of a6Band component.
     * @return the initialized component instance
     */
    public ChoiceGroup getA6Band() {
        if (a6Band == null) {//GEN-END:|168-getter|0|168-preInit
            // write pre-init user code here
            a6Band = new ChoiceGroup("A band", Choice.POPUP);//GEN-BEGIN:|168-getter|1|168-postInit
            a6Band.append("Brown", null);
            a6Band.append("Red", null);
            a6Band.append("Orange", null);
            a6Band.append("Yellow", null);
            a6Band.append("Green", null);
            a6Band.append("Blue", null);
            a6Band.append("Violet", null);
            a6Band.append("Gray", null);
            a6Band.append("White", null);
            a6Band.setSelectedFlags(new boolean[] { false, false, false, false, false, false, false, false, false });//GEN-END:|168-getter|1|168-postInit
            // write post-init user code here
        }//GEN-BEGIN:|168-getter|2|
        return a6Band;
    }
    //</editor-fold>//GEN-END:|168-getter|2|
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: b6Band ">//GEN-BEGIN:|169-getter|0|169-preInit
    /**
     * Returns an initiliazed instance of b6Band component.
     * @return the initialized component instance
     */
    public ChoiceGroup getB6Band() {
        if (b6Band == null) {//GEN-END:|169-getter|0|169-preInit
            // write pre-init user code here
            b6Band = new ChoiceGroup("B band", Choice.POPUP);//GEN-BEGIN:|169-getter|1|169-postInit
            b6Band.append("Black", null);
            b6Band.append("Red", null);
            b6Band.append("Orange", null);
            b6Band.append("Yellow", null);
            b6Band.append("Green", null);
            b6Band.append("Blue", null);
            b6Band.append("Violet", null);
            b6Band.append("Gray", null);
            b6Band.append("White", null);
            b6Band.setSelectedFlags(new boolean[] { false, false, false, false, false, false, false, false, false });//GEN-END:|169-getter|1|169-postInit
            // write post-init user code here
        }//GEN-BEGIN:|169-getter|2|
        return b6Band;
    }
    //</editor-fold>//GEN-END:|169-getter|2|
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: c6Band ">//GEN-BEGIN:|170-getter|0|170-preInit
    /**
     * Returns an initiliazed instance of c6Band component.
     * @return the initialized component instance
     */
    public ChoiceGroup getC6Band() {
        if (c6Band == null) {//GEN-END:|170-getter|0|170-preInit
            // write pre-init user code here
            c6Band = new ChoiceGroup("C band", Choice.POPUP);//GEN-BEGIN:|170-getter|1|170-postInit
            c6Band.append("Black", null);
            c6Band.append("Brown", null);
            c6Band.append("Red", null);
            c6Band.append("Orange", null);
            c6Band.append("Yellow", null);
            c6Band.append("Green", null);
            c6Band.append("Blue", null);
            c6Band.append("Violet", null);
            c6Band.append("Gray", null);
            c6Band.append("White", null);
            c6Band.setSelectedFlags(new boolean[] { false, false, false, false, false, false, false, false, false, false });//GEN-END:|170-getter|1|170-postInit
            // write post-init user code here
        }//GEN-BEGIN:|170-getter|2|
        return c6Band;
    }
    //</editor-fold>//GEN-END:|170-getter|2|
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: d6Band ">//GEN-BEGIN:|171-getter|0|171-preInit
    /**
     * Returns an initiliazed instance of d6Band component.
     * @return the initialized component instance
     */
    public ChoiceGroup getD6Band() {
        if (d6Band == null) {//GEN-END:|171-getter|0|171-preInit
            // write pre-init user code here
            d6Band = new ChoiceGroup("D band", Choice.POPUP);//GEN-BEGIN:|171-getter|1|171-postInit
            d6Band.append("Black", null);
            d6Band.append("Brown", null);
            d6Band.append("Red", null);
            d6Band.append("Orange", null);
            d6Band.append("Yellow", null);
            d6Band.append("Green", null);
            d6Band.append("Blue", null);
            d6Band.append("Violet", null);
            d6Band.append("Gray", null);
            d6Band.append("White", null);
            d6Band.setSelectedFlags(new boolean[] { false, false, false, false, false, false, false, false, false, false });//GEN-END:|171-getter|1|171-postInit
            // write post-init user code here
        }//GEN-BEGIN:|171-getter|2|
        return d6Band;
    }
    //</editor-fold>//GEN-END:|171-getter|2|
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: e6Band ">//GEN-BEGIN:|172-getter|0|172-preInit
    /**
     * Returns an initiliazed instance of e6Band component.
     * @return the initialized component instance
     */
    public ChoiceGroup getE6Band() {
        if (e6Band == null) {//GEN-END:|172-getter|0|172-preInit
            // write pre-init user code here
            e6Band = new ChoiceGroup("Tolerance", Choice.POPUP);//GEN-BEGIN:|172-getter|1|172-postInit
            e6Band.append("Brown", null);
            e6Band.append("Red", null);
            e6Band.append("Gold", null);
            e6Band.append("Silver", null);
            e6Band.setSelectedFlags(new boolean[] { false, false, false, false });//GEN-END:|172-getter|1|172-postInit
            // write post-init user code here
        }//GEN-BEGIN:|172-getter|2|
        return e6Band;
    }
    //</editor-fold>//GEN-END:|172-getter|2|
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: f6Band ">//GEN-BEGIN:|173-getter|0|173-preInit
    /**
     * Returns an initiliazed instance of f6Band component.
     * @return the initialized component instance
     */
    public ChoiceGroup getF6Band() {
        if (f6Band == null) {//GEN-END:|173-getter|0|173-preInit
            // write pre-init user code here
            f6Band = new ChoiceGroup("Temperature", Choice.POPUP);//GEN-BEGIN:|173-getter|1|173-postInit
            f6Band.append("Brown", null);
            f6Band.append("Red", null);
            f6Band.append("Orange", null);
            f6Band.append("Yellow", null);
            f6Band.setSelectedFlags(new boolean[] { false, false, false, false });//GEN-END:|173-getter|1|173-postInit
            // write post-init user code here
        }//GEN-BEGIN:|173-getter|2|
        return f6Band;
    }
    //</editor-fold>//GEN-END:|173-getter|2|



    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: stopCommand ">//GEN-BEGIN:|196-getter|0|196-preInit
    /**
     * Returns an initiliazed instance of stopCommand component.
     * @return the initialized component instance
     */
    public Command getStopCommand() {
        if (stopCommand == null) {//GEN-END:|196-getter|0|196-preInit
            // write pre-init user code here
            stopCommand = new Command("Stop", Command.STOP, 0);//GEN-LINE:|196-getter|1|196-postInit
            // write post-init user code here
        }//GEN-BEGIN:|196-getter|2|
        return stopCommand;
    }
    //</editor-fold>//GEN-END:|196-getter|2|







    /**
     * Returns a display instance.
     * @return the display instance.
     */
    public Display getDisplay () {
        return Display.getDisplay(this);
    }

    /**
     * Exits MIDlet.
     */
    public void exitMIDlet() {
        switchDisplayable (null, null);
        destroyApp(true);
        notifyDestroyed();
    }

    /**
     * Called when MIDlet is started.
     * Checks whether the MIDlet have been already started and initialize/starts or resumes the MIDlet.
     */
    public void startApp() {
        if (midletPaused) {
            resumeMIDlet ();
        } else {
            initialize ();
            startMIDlet ();
        }
        midletPaused = false;
    }

    /**
     * Called when MIDlet is paused.
     */
    public void pauseApp() {
        midletPaused = true;
    }

    /**
     * Called to signal the MIDlet to terminate.
     * @param unconditional if true, then the MIDlet has to be unconditionally terminated and all resources has to be released.
     */
    public void destroyApp(boolean unconditional) {
    }

}
